package com.xtpt.disaster.utils;

import com.xtpt.disaster.bean.DbnodeInfo;
import com.xtpt.disaster.common.DM.DMCmdBuilder;
import com.xtpt.disaster.common.DM.DMConfig;
import com.xtpt.disaster.common.consts.OSTypeEenum;
import org.apache.commons.lang3.builder.ToStringExclude;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.List;

import static org.apache.commons.lang3.StringUtils.split;

@Component
public class TestInterface {


    @Test
    public void test() {

        String path = "/opt/test/DATABASE/MYSQL/0/2021-11/381844278300135424/test1_2021-11-19-16-30-38";
        String[] split = path.split("_");
        String s = "";
        for (int i = 0; i < split.length - 1; i++) {
            s += split[i];
        }
        Integer l = s.split("/").length;
        String[] splitpath = s.split("/");
        int i = path.lastIndexOf("/");
        String filename = path.substring(i);
        System.out.println(filename);
        String s1 = path.substring(0, i);
        System.out.println(s1);
//        System.out.println(String.join(splitpath));
        System.out.println(s.split("/")[l - 1]);
        System.out.println(split);
        System.out.println("print");
    }

    @Test
    public void OracleBackup() {


    }




    @Test
    public void DatabaseBackup() throws IOException, InterruptedException {
//        DatabaseUtil.entirelyBackup("192.168.1.64", "root", "123456", "mybatis1","/Users/wangqitai/bak","bak_mybatis.sql" );

    }

    @Test
    public void DatabaseRecover() throws IOException, InterruptedException {
//        DatabaseUtil.recover("192.168.1.41", "root", "123456", "test_backup", "/Users/wangqitai/bak", "bak_mybatis.sql");

    }


    @Test
    public void testCmd() throws Exception {
        DbnodeInfo client=new DbnodeInfo();
        client.setNodeOsType(OSTypeEenum.LINUX.getValue());
        DMCmdBuilder builder=new DMCmdBuilder();
//        builder.setClientDBNodeInfo(client);
    }
}
